#include <bits/stdc++.h>
using namespace std;
struct c
{
    int d;//come from
    int v;//start v
    int a;//add v
}a[100005];
const bool operator<(const c &xx1,const c &xx2)
{
    if(xx1.d!=xx2.d)return xx1.d<xx2.d;
    if(xx1.v!=xx2.v)return xx1.v<xx2.v;
    return xx1.a<xx2.a;
}
struct d
{
    int w;
    vector<int> car;//see how many and what is not local car
    int minn;//the less being seen not locally car's seeing time
    int mx;//which car
};
map<int,set<int> > c;
const bool operator<(const d &xx1,const d &xx2)
{
    if(xx1.car.size()!=xx2.car.size())return xx1.car.size()<xx2.car.size();
    if(xx1.minn!=xx2.minn)return xx1.minn>xx2.minn;
    return xx1.w<xx2.w;
}
set<d> b;
map<int,set<d>::iterator> e;
int T,n,m,l,v,minn;
d t;
bool OK()
{
    for(set<d>::iterator it=b.begin();it!=b.end();it++)
    {
        d t=*it;
        if(t.minn>1)
            return true;
    }
    return false;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    t.minn=2147483647;
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>l>>v;
        int ccc=0;
        for(int i=1;i<=n;i++)
            cin>>a[i].d>>a[i].v>>a[i].a;
        sort(a+1,a+n+1);
        for(int i=1;i<=m;i++)
        {
            cin>>t.w;
            b.insert(t);
        }
        for(set<d>::iterator it=b.begin();it!=b.end();it++)
        {
            t=*it;
            e[t.w]=it;
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i].v<=v && a[i].a<=0)
                continue;
            else if(a[i].a>=0)
            {
                if(a[i].v<=v)
                {
                    if( (v-a[i].v)%a[i].a )
                    {
                        a[i].a+=( ( a[i].a - ( (v-a[i].v) % a[i].a ) + a[i].v) / a[i].a)
                    }
                    else
                    {
                        a[i].a+=( (v-a[i].v) / a[i].a );
                    }
                    if( a[i].a > l)
                        continue;
                }
                bool flag=true;
                minn=0;
                for(set<d>::iterator it=b.begin();it!=b.end();it++)
                {
                    t=*it;
                    if(t.w>=a[i].d)
                    {
                        c[i].insert(t.w);
                        b.erase(it);
                        t.car.insert(t.car.begin(),i);
                        b.insert(t);
                        minn++;
                        if(flag)
                        {
                            flag=false;
                            ccc++;
                        }
                    }
                }
                if(minn)
                    for(set<d>::iterator it=b.begin();it!=b.end();it++)
                    {
                        t=*it;
                        if(minn<t.minn)
                        {
                            b.erase(it);
                            t.minn=minn;
                            t.mx=i;
                            b.insert(t);
                        }
                    }
            }
            else if(a[i].v>v && a[i].a<0)
            {
                bool flag=true;
                minn=0;
                double be=a[i].a,en=a[i].a+( v*v - a[i].v*a[i].v ) / (2 * a[i].a);
                for(set<d>::iterator it=b.begin();it!=b.end();it++)
                {
                    t=*it;
                    if(be <= t.w && t.w < en)
                    {
                        c[i].insert(t.w);
                        b.erase(it);
                        t.car.insert(t.car.begin(),i);
                        b.insert(t);
                        minn++;
                        if(flag)
                        {
                            flag=false;
                            ccc++;
                        }
                    }
                }
                if(minn)
                    for(set<d>::iterator it=b.begin();it!=b.end();it++)
                    {
                        t=*it;
                        if(minn<t.minn)
                        {
                            b.erase(it);
                            t.minn=minn;
                            t.mx=i;
                            b.insert(t);
                        }
                    }
            }
        }
        cout<<ccc;
        int ans=0;
        while(OK())
        {
            set<d>::iterator it=b.begin();
            d t=*it;
            b.erase(it);
            for()
        }
    }
    for(set<d>::iterator it=b.begin();it!=b.end();it++)
    {
        t=*it;
        cout<<t.w<<' '<<t.minn<<' '<<t.mx<<endl;
    }
    return 0;
}
